<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
</head>

<body>
  <script>
    // 
    class Animal {
      constructor(kemu, color) {
        this.kemu = kemu;
        this.color = color;
      }
      eat() {
        console.log(this.kemu + "吃")
      }
    }
    // 猫类继承动物类
    // es6类的继承
    // 1 class子类 extends 父类{}
    // 2.必须在子类的构造器中写super("给父类传参")
    class Cat extends Animal {
      constructor(name, age) {
        super("猫科", "橘色");
        this.name = name;
        this.age = age;
      }
      run() {
        console.log("跑")
      }
    }
    var tom = new Cat("汤姆", 18);
    // 继承后 子类可以访问父类的属性和方法
    tom.eat()
    console.log(tom.color)








  </script>
</body>

</html>